package com.joker.order.config;

import com.alipay.api.AlipayApiException;
import com.alipay.api.AlipayConfig;
import com.alipay.api.DefaultAlipayClient;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author lemon
 * @date 2024/12/30 20:26
 **/
@Configuration
@ConfigurationProperties(prefix = "alipay")
@Data
public class PayConfig {
    private String privateKey;
    private String alipayPublicKey;
    private String serverUrl;
    private String appId;
    private String format;
    private String charset;
    private String signType;
    private String notifyUrl;
    private String returnUrl;

    @Bean
    public AlipayConfig alipayConfig(){
        AlipayConfig alipayConfig = new AlipayConfig();
        alipayConfig.setServerUrl(serverUrl);
        alipayConfig.setAppId(appId);
        alipayConfig.setPrivateKey(privateKey);
        alipayConfig.setFormat(format);
        alipayConfig.setAlipayPublicKey(alipayPublicKey);
        alipayConfig.setCharset(charset);
        alipayConfig.setSignType(signType);
        return alipayConfig;
    }
}
